<template>
  <div class="accounts-page">
    <!-- 财务概览卡片 -->
    <el-row :gutter="20" class="overview-cards">
      <el-col :xs="24" :sm="12" :md="6">
        <el-card class="overview-card">
          <div class="card-content">
            <div class="card-icon income">
              <el-icon size="24"><TrendCharts /></el-icon>
            </div>
            <div class="card-info">
              <div class="card-value">¥{{ formatNumber(financeOverview.totalIncome) }}</div>
              <div class="card-label">总收入</div>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="12" :md="6">
        <el-card class="overview-card">
          <div class="card-content">
            <div class="card-icon expense">
              <el-icon size="24"><Money /></el-icon>
            </div>
            <div class="card-info">
              <div class="card-value">¥{{ formatNumber(financeOverview.totalExpense) }}</div>
              <div class="card-label">总支出</div>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="12" :md="6">
        <el-card class="overview-card">
          <div class="card-content">
            <div class="card-icon receivable">
              <el-icon size="24"><CreditCard /></el-icon>
            </div>
            <div class="card-info">
              <div class="card-value">¥{{ formatNumber(financeOverview.totalReceivable) }}</div>
              <div class="card-label">应收账款</div>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="12" :md="6">
        <el-card class="overview-card">
          <div class="card-content">
            <div class="card-icon payable">
              <el-icon size="24"><Wallet /></el-icon>
            </div>
            <div class="card-info">
              <div class="card-value">¥{{ formatNumber(financeOverview.totalPayable) }}</div>
              <div class="card-label">应付账款</div>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <!-- 财务管理主区域 -->
    <el-card>
      <template #header>
        <div class="page-header">
          <h3>财务管理</h3>
          <div class="header-actions">
            <el-button type="success" @click="showIncomeDialog">
              <el-icon><Plus /></el-icon>
              收入记录
            </el-button>
            <el-button type="warning" @click="showExpenseDialog">
              <el-icon><Minus /></el-icon>
              支出记录
            </el-button>
            <el-button type="primary" @click="showReceivableDialog">
              <el-icon><CreditCard /></el-icon>
              应收管理
            </el-button>
            <el-button type="info" @click="showPayableDialog">
              <el-icon><Wallet /></el-icon>
              应付管理
            </el-button>
          </div>
        </div>
      </template>

      <!-- 搜索区域 -->
      <div class="search-area">
        <el-form :model="searchForm" inline>
          <el-form-item label="类型">
            <el-select v-model="searchForm.type" placeholder="请选择类型" clearable>
              <el-option label="收入" value="收入" />
              <el-option label="支出" value="支出" />
              <el-option label="应收" value="应收" />
              <el-option label="应付" value="应付" />
            </el-select>
          </el-form-item>
          <el-form-item label="账户">
            <el-select v-model="searchForm.account" placeholder="请选择账户" clearable>
              <el-option label="现金" value="现金" />
              <el-option label="银行存款" value="银行存款" />
              <el-option label="应收账款" value="应收账款" />
              <el-option label="应付账款" value="应付账款" />
            </el-select>
          </el-form-item>
          <el-form-item label="日期范围">
            <el-date-picker
              v-model="searchForm.dateRange"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              format="YYYY-MM-DD"
              value-format="YYYY-MM-DD"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="handleSearch">
              <el-icon><Search /></el-icon>
              搜索
            </el-button>
            <el-button @click="handleReset">
              <el-icon><Refresh /></el-icon>
              重置
            </el-button>
          </el-form-item>
        </el-form>
      </div>

      <!-- 表格区域 -->
      <el-table :data="tableData" v-loading="loading" stripe>
        <el-table-column prop="id" label="ID" width="80" />
        <el-table-column prop="type" label="类型" width="100">
          <template #default="{ row }">
            <el-tag :type="getTypeTagType(row.type)">
              {{ row.type }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="account" label="账户" width="120" />
        <el-table-column prop="amount" label="金额" width="120">
          <template #default="{ row }">
            <span :class="getAmountClass(row.type)">
              {{ row.type === '支出' || row.type === '应付' ? '-' : '+' }}¥{{ formatNumber(row.amount) }}
            </span>
          </template>
        </el-table-column>
        <el-table-column prop="description" label="描述" width="200" />
        <el-table-column prop="relatedOrder" label="关联订单" width="150" />
        <el-table-column prop="status" label="状态" width="100">
          <template #default="{ row }">
            <el-tag :type="getStatusTagType(row.status)">
              {{ row.status }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="date" label="日期" width="120" />
        <el-table-column prop="operator" label="操作人" width="100" />
        <el-table-column label="操作" width="150" fixed="right">
          <template #default="{ row }">
            <el-button type="primary" size="small" @click="handleView(row)">
              查看
            </el-button>
            <el-button 
              v-if="row.status === '待确认'" 
              type="success" 
              size="small" 
              @click="handleConfirm(row)"
            >
              确认
            </el-button>
            <el-button 
              v-if="row.status === '待确认'" 
              type="danger" 
              size="small" 
              @click="handleCancel(row)"
            >
              取消
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <div class="pagination">
        <el-pagination
          v-model:current-page="pagination.currentPage"
          v-model:page-size="pagination.pageSize"
          :page-sizes="[10, 20, 50, 100]"
          :total="pagination.total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </el-card>

    <!-- 收入记录对话框 -->
    <el-dialog
      v-model="incomeDialogVisible"
      title="收入记录"
      width="600px"
    >
      <el-form
        ref="incomeFormRef"
        :model="incomeForm"
        :rules="incomeRules"
        label-width="100px"
      >
        <el-form-item label="收入类型" prop="type">
          <el-select v-model="incomeForm.type" placeholder="请选择收入类型" style="width: 100%">
            <el-option label="销售收入" value="销售收入" />
            <el-option label="其他收入" value="其他收入" />
            <el-option label="投资收益" value="投资收益" />
          </el-select>
        </el-form-item>
        
        <el-form-item label="账户" prop="account">
          <el-select v-model="incomeForm.account" placeholder="请选择账户" style="width: 100%">
            <el-option label="现金" value="现金" />
            <el-option label="银行存款" value="银行存款" />
          </el-select>
        </el-form-item>

        <el-form-item label="金额" prop="amount">
          <el-input-number 
            v-model="incomeForm.amount" 
            :min="0" 
            :precision="2"
            style="width: 100%"
            placeholder="请输入金额"
          />
        </el-form-item>

        <el-form-item label="描述" prop="description">
          <el-input 
            v-model="incomeForm.description" 
            type="textarea" 
            :rows="3"
            placeholder="请输入收入描述" 
          />
        </el-form-item>

        <el-form-item label="关联订单" prop="relatedOrder">
          <el-input v-model="incomeForm.relatedOrder" placeholder="请输入关联订单号" />
        </el-form-item>

        <el-form-item label="日期" prop="date">
          <el-date-picker
            v-model="incomeForm.date"
            type="date"
            placeholder="请选择日期"
            style="width: 100%"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>
      </el-form>

      <template #footer>
        <el-button @click="incomeDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="handleIncomeSubmit" :loading="incomeLoading">
          确定
        </el-button>
      </template>
    </el-dialog>

    <!-- 支出记录对话框 -->
    <el-dialog
      v-model="expenseDialogVisible"
      title="支出记录"
      width="600px"
    >
      <el-form
        ref="expenseFormRef"
        :model="expenseForm"
        :rules="expenseRules"
        label-width="100px"
      >
        <el-form-item label="支出类型" prop="type">
          <el-select v-model="expenseForm.type" placeholder="请选择支出类型" style="width: 100%">
            <el-option label="采购支出" value="采购支出" />
            <el-option label="运营费用" value="运营费用" />
            <el-option label="管理费用" value="管理费用" />
            <el-option label="其他支出" value="其他支出" />
          </el-select>
        </el-form-item>
        
        <el-form-item label="账户" prop="account">
          <el-select v-model="expenseForm.account" placeholder="请选择账户" style="width: 100%">
            <el-option label="现金" value="现金" />
            <el-option label="银行存款" value="银行存款" />
          </el-select>
        </el-form-item>

        <el-form-item label="金额" prop="amount">
          <el-input-number 
            v-model="expenseForm.amount" 
            :min="0" 
            :precision="2"
            style="width: 100%"
            placeholder="请输入金额"
          />
        </el-form-item>

        <el-form-item label="描述" prop="description">
          <el-input 
            v-model="expenseForm.description" 
            type="textarea" 
            :rows="3"
            placeholder="请输入支出描述" 
          />
        </el-form-item>

        <el-form-item label="关联订单" prop="relatedOrder">
          <el-input v-model="expenseForm.relatedOrder" placeholder="请输入关联订单号" />
        </el-form-item>

        <el-form-item label="日期" prop="date">
          <el-date-picker
            v-model="expenseForm.date"
            type="date"
            placeholder="请选择日期"
            style="width: 100%"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>
      </el-form>

      <template #footer>
        <el-button @click="expenseDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="handleExpenseSubmit" :loading="expenseLoading">
          确定
        </el-button>
      </template>
    </el-dialog>

    <!-- 应收管理对话框 -->
    <el-dialog
      v-model="receivableDialogVisible"
      title="应收管理"
      width="600px"
    >
      <el-form
        ref="receivableFormRef"
        :model="receivableForm"
        :rules="receivableRules"
        label-width="100px"
      >
        <el-form-item label="客户" prop="customer">
          <el-input v-model="receivableForm.customer" placeholder="请输入客户名称" />
        </el-form-item>
        
        <el-form-item label="金额" prop="amount">
          <el-input-number 
            v-model="receivableForm.amount" 
            :min="0" 
            :precision="2"
            style="width: 100%"
            placeholder="请输入应收金额"
          />
        </el-form-item>

        <el-form-item label="到期日期" prop="dueDate">
          <el-date-picker
            v-model="receivableForm.dueDate"
            type="date"
            placeholder="请选择到期日期"
            style="width: 100%"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>

        <el-form-item label="描述" prop="description">
          <el-input 
            v-model="receivableForm.description" 
            type="textarea" 
            :rows="3"
            placeholder="请输入应收描述" 
          />
        </el-form-item>

        <el-form-item label="关联订单" prop="relatedOrder">
          <el-input v-model="receivableForm.relatedOrder" placeholder="请输入关联订单号" />
        </el-form-item>
      </el-form>

      <template #footer>
        <el-button @click="receivableDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="handleReceivableSubmit" :loading="receivableLoading">
          确定
        </el-button>
      </template>
    </el-dialog>

    <!-- 应付管理对话框 -->
    <el-dialog
      v-model="payableDialogVisible"
      title="应付管理"
      width="600px"
    >
      <el-form
        ref="payableFormRef"
        :model="payableForm"
        :rules="payableRules"
        label-width="100px"
      >
        <el-form-item label="供应商" prop="supplier">
          <el-input v-model="payableForm.supplier" placeholder="请输入供应商名称" />
        </el-form-item>
        
        <el-form-item label="金额" prop="amount">
          <el-input-number 
            v-model="payableForm.amount" 
            :min="0" 
            :precision="2"
            style="width: 100%"
            placeholder="请输入应付金额"
          />
        </el-form-item>

        <el-form-item label="到期日期" prop="dueDate">
          <el-date-picker
            v-model="payableForm.dueDate"
            type="date"
            placeholder="请选择到期日期"
            style="width: 100%"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>

        <el-form-item label="描述" prop="description">
          <el-input 
            v-model="payableForm.description" 
            type="textarea" 
            :rows="3"
            placeholder="请输入应付描述" 
          />
        </el-form-item>

        <el-form-item label="关联订单" prop="relatedOrder">
          <el-input v-model="payableForm.relatedOrder" placeholder="请输入关联订单号" />
        </el-form-item>
      </el-form>

      <template #footer>
        <el-button @click="payableDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="handlePayableSubmit" :loading="payableLoading">
          确定
        </el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'

// 响应式数据
const loading = ref(false)
const incomeDialogVisible = ref(false)
const expenseDialogVisible = ref(false)
const receivableDialogVisible = ref(false)
const payableDialogVisible = ref(false)
const incomeLoading = ref(false)
const expenseLoading = ref(false)
const receivableLoading = ref(false)
const payableLoading = ref(false)
const incomeFormRef = ref()
const expenseFormRef = ref()
const receivableFormRef = ref()
const payableFormRef = ref()

// 财务概览数据
const financeOverview = reactive({
  totalIncome: 1250000,
  totalExpense: 850000,
  totalReceivable: 150000,
  totalPayable: 80000
})

// 搜索表单
const searchForm = reactive({
  type: '',
  account: '',
  dateRange: []
})

// 收入表单
const incomeForm = reactive({
  type: '',
  account: '',
  amount: 0,
  description: '',
  relatedOrder: '',
  date: ''
})

// 支出表单
const expenseForm = reactive({
  type: '',
  account: '',
  amount: 0,
  description: '',
  relatedOrder: '',
  date: ''
})

// 应收表单
const receivableForm = reactive({
  customer: '',
  amount: 0,
  dueDate: '',
  description: '',
  relatedOrder: ''
})

// 应付表单
const payableForm = reactive({
  supplier: '',
  amount: 0,
  dueDate: '',
  description: '',
  relatedOrder: ''
})

// 表单验证规则
const incomeRules = {
  type: [
    { required: true, message: '请选择收入类型', trigger: 'change' }
  ],
  account: [
    { required: true, message: '请选择账户', trigger: 'change' }
  ],
  amount: [
    { required: true, message: '请输入金额', trigger: 'blur' }
  ],
  date: [
    { required: true, message: '请选择日期', trigger: 'change' }
  ]
}

const expenseRules = {
  type: [
    { required: true, message: '请选择支出类型', trigger: 'change' }
  ],
  account: [
    { required: true, message: '请选择账户', trigger: 'change' }
  ],
  amount: [
    { required: true, message: '请输入金额', trigger: 'blur' }
  ],
  date: [
    { required: true, message: '请选择日期', trigger: 'change' }
  ]
}

const receivableRules = {
  customer: [
    { required: true, message: '请输入客户名称', trigger: 'blur' }
  ],
  amount: [
    { required: true, message: '请输入应收金额', trigger: 'blur' }
  ],
  dueDate: [
    { required: true, message: '请选择到期日期', trigger: 'change' }
  ]
}

const payableRules = {
  supplier: [
    { required: true, message: '请输入供应商名称', trigger: 'blur' }
  ],
  amount: [
    { required: true, message: '请输入应付金额', trigger: 'blur' }
  ],
  dueDate: [
    { required: true, message: '请选择到期日期', trigger: 'change' }
  ]
}

// 分页数据
const pagination = reactive({
  currentPage: 1,
  pageSize: 10,
  total: 0
})

// 表格数据
const tableData = ref([
  {
    id: 1,
    type: '收入',
    account: '银行存款',
    amount: 15000,
    description: '销售订单收入',
    relatedOrder: 'SO20240115001',
    status: '已确认',
    date: '2024-01-15',
    operator: '张三'
  },
  {
    id: 2,
    type: '支出',
    account: '现金',
    amount: 5000,
    description: '采购支出',
    relatedOrder: 'PO20240115001',
    status: '已确认',
    date: '2024-01-15',
    operator: '李四'
  },
  {
    id: 3,
    type: '应收',
    account: '应收账款',
    amount: 25000,
    description: '客户应收账款',
    relatedOrder: 'SO20240115002',
    status: '待确认',
    date: '2024-01-15',
    operator: '王五'
  },
  {
    id: 4,
    type: '应付',
    account: '应付账款',
    amount: 12000,
    description: '供应商应付账款',
    relatedOrder: 'PO20240115002',
    status: '待确认',
    date: '2024-01-15',
    operator: '赵六'
  }
])

// 计算属性
const getTypeTagType = (type) => {
  const typeMap = {
    '收入': 'success',
    '支出': 'warning',
    '应收': 'primary',
    '应付': 'info'
  }
  return typeMap[type] || 'info'
}

const getStatusTagType = (status) => {
  const statusMap = {
    '已确认': 'success',
    '待确认': 'warning',
    '已取消': 'danger'
  }
  return statusMap[status] || 'info'
}

const getAmountClass = (type) => {
  return type === '支出' || type === '应付' ? 'amount-expense' : 'amount-income'
}

// 方法
const formatNumber = (value) => {
  if (typeof value === 'number') {
    return value.toLocaleString()
  }
  return value
}

const loadData = () => {
  loading.value = true
  setTimeout(() => {
    pagination.total = tableData.value.length
    loading.value = false
  }, 500)
}

const handleSearch = () => {
  pagination.currentPage = 1
  loadData()
}

const handleReset = () => {
  Object.assign(searchForm, {
    type: '',
    account: '',
    dateRange: []
  })
  handleSearch()
}

const handleView = (row) => {
  ElMessage.info('查看详情功能')
}

const handleConfirm = async (row) => {
  try {
    await ElMessageBox.confirm('确定要确认该记录吗？', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })
    
    const index = tableData.value.findIndex(item => item.id === row.id)
    if (index > -1) {
      tableData.value[index].status = '已确认'
      ElMessage.success('确认成功')
      loadData()
    }
  } catch {
    // 用户取消操作
  }
}

const handleCancel = async (row) => {
  try {
    await ElMessageBox.confirm('确定要取消该记录吗？', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })
    
    const index = tableData.value.findIndex(item => item.id === row.id)
    if (index > -1) {
      tableData.value[index].status = '已取消'
      ElMessage.success('取消成功')
      loadData()
    }
  } catch {
    // 用户取消操作
  }
}

const showIncomeDialog = () => {
  incomeDialogVisible.value = true
  resetIncomeForm()
}

const showExpenseDialog = () => {
  expenseDialogVisible.value = true
  resetExpenseForm()
}

const showReceivableDialog = () => {
  receivableDialogVisible.value = true
  resetReceivableForm()
}

const showPayableDialog = () => {
  payableDialogVisible.value = true
  resetPayableForm()
}

const handleIncomeSubmit = async () => {
  if (!incomeFormRef.value) return

  try {
    await incomeFormRef.value.validate()
    incomeLoading.value = true

    // 模拟API调用
    await new Promise(resolve => setTimeout(resolve, 1000))

    // 添加新记录
    const newRecord = {
      id: Date.now(),
      type: '收入',
      account: incomeForm.account,
      amount: incomeForm.amount,
      description: incomeForm.description,
      relatedOrder: incomeForm.relatedOrder,
      status: '待确认',
      date: incomeForm.date,
      operator: '当前用户'
    }
    
    tableData.value.unshift(newRecord)
    ElMessage.success('收入记录添加成功')
    incomeDialogVisible.value = false
    loadData()
  } catch (error) {
    console.error('表单验证失败:', error)
  } finally {
    incomeLoading.value = false
  }
}

const handleExpenseSubmit = async () => {
  if (!expenseFormRef.value) return

  try {
    await expenseFormRef.value.validate()
    expenseLoading.value = true

    // 模拟API调用
    await new Promise(resolve => setTimeout(resolve, 1000))

    // 添加新记录
    const newRecord = {
      id: Date.now(),
      type: '支出',
      account: expenseForm.account,
      amount: expenseForm.amount,
      description: expenseForm.description,
      relatedOrder: expenseForm.relatedOrder,
      status: '待确认',
      date: expenseForm.date,
      operator: '当前用户'
    }
    
    tableData.value.unshift(newRecord)
    ElMessage.success('支出记录添加成功')
    expenseDialogVisible.value = false
    loadData()
  } catch (error) {
    console.error('表单验证失败:', error)
  } finally {
    expenseLoading.value = false
  }
}

const handleReceivableSubmit = async () => {
  if (!receivableFormRef.value) return

  try {
    await receivableFormRef.value.validate()
    receivableLoading.value = true

    // 模拟API调用
    await new Promise(resolve => setTimeout(resolve, 1000))

    // 添加新记录
    const newRecord = {
      id: Date.now(),
      type: '应收',
      account: '应收账款',
      amount: receivableForm.amount,
      description: receivableForm.description,
      relatedOrder: receivableForm.relatedOrder,
      status: '待确认',
      date: receivableForm.dueDate,
      operator: '当前用户'
    }
    
    tableData.value.unshift(newRecord)
    ElMessage.success('应收记录添加成功')
    receivableDialogVisible.value = false
    loadData()
  } catch (error) {
    console.error('表单验证失败:', error)
  } finally {
    receivableLoading.value = false
  }
}

const handlePayableSubmit = async () => {
  if (!payableFormRef.value) return

  try {
    await payableFormRef.value.validate()
    payableLoading.value = true

    // 模拟API调用
    await new Promise(resolve => setTimeout(resolve, 1000))

    // 添加新记录
    const newRecord = {
      id: Date.now(),
      type: '应付',
      account: '应付账款',
      amount: payableForm.amount,
      description: payableForm.description,
      relatedOrder: payableForm.relatedOrder,
      status: '待确认',
      date: payableForm.dueDate,
      operator: '当前用户'
    }
    
    tableData.value.unshift(newRecord)
    ElMessage.success('应付记录添加成功')
    payableDialogVisible.value = false
    loadData()
  } catch (error) {
    console.error('表单验证失败:', error)
  } finally {
    payableLoading.value = false
  }
}

const resetIncomeForm = () => {
  Object.assign(incomeForm, {
    type: '',
    account: '',
    amount: 0,
    description: '',
    relatedOrder: '',
    date: ''
  })
  incomeFormRef.value?.clearValidate()
}

const resetExpenseForm = () => {
  Object.assign(expenseForm, {
    type: '',
    account: '',
    amount: 0,
    description: '',
    relatedOrder: '',
    date: ''
  })
  expenseFormRef.value?.clearValidate()
}

const resetReceivableForm = () => {
  Object.assign(receivableForm, {
    customer: '',
    amount: 0,
    dueDate: '',
    description: '',
    relatedOrder: ''
  })
  receivableFormRef.value?.clearValidate()
}

const resetPayableForm = () => {
  Object.assign(payableForm, {
    supplier: '',
    amount: 0,
    dueDate: '',
    description: '',
    relatedOrder: ''
  })
  payableFormRef.value?.clearValidate()
}

const handleSizeChange = (size) => {
  pagination.pageSize = size
  loadData()
}

const handleCurrentChange = (page) => {
  pagination.currentPage = page
  loadData()
}

// 生命周期
onMounted(() => {
  loadData()
})
</script>

<style scoped>
.accounts-page {
  padding: 0;
}

.overview-cards {
  margin-bottom: 20px;
}

.overview-card {
  border: none;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.card-content {
  display: flex;
  align-items: center;
}

.card-icon {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  color: white;
}

.card-icon.income {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.card-icon.expense {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
}

.card-icon.receivable {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.card-icon.payable {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.card-info {
  flex: 1;
}

.card-value {
  font-size: 24px;
  font-weight: 600;
  color: #303133;
  margin-bottom: 4px;
}

.card-label {
  font-size: 14px;
  color: #909399;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-header h3 {
  margin: 0;
  color: #303133;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.search-area {
  margin-bottom: 20px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 4px;
}

.pagination {
  margin-top: 20px;
  text-align: right;
}

.amount-income {
  color: #67c23a;
  font-weight: 600;
}

.amount-expense {
  color: #f56c6c;
  font-weight: 600;
}
</style>
